<?php
namespace app\home\controller;
use think\Controller;
use think\Db;
use think\Request;


class Base extends Controller
{
	public function _initialize()
    {
        //导航 nav
        $nav=db('cate')->where('show',1)->select();
        
        $this->assign('_nav',$nav);
        //主体信息 SEO
        $seo=db('basic')->where('id',1)->find();
        $this->assign('_seo',$seo);
        // 最新动态 postion_new
        $postion_new = db('article')->order('id desc')->limit(5)->select();
        $this->assign('postion_new',$postion_new);
        // 统计文章数量 article_count
        $article_count=db('article')->count();
        $this->assign('article_count',$article_count);
        // banner图片
        $banner=db('banner')->select();
        $this->assign('banner',$banner);
        // 搜索 search
        if(Request::instance()->isPost()){
            $data = db('article')->where('title','like','%'.input('keyword').'%')->order('id desc')->paginate(8);
        }else{
            $data = db('article')->order('id desc')->paginate(8);
        }
        $pagef=$data->render();
        $this->assign('search',$data);
        $this->assign('page', $pagef);
    }
}
